<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>自定义按键修饰符</title>
  </head>

  <body>
    <pre>
        自定义按键修饰符，是指 Vue 给提供的按键满足不了业务需求，这时候需要自定义，
        但是 Vue 给提供的一般已经满足业务需求  
    </pre>
    <div class="box">
      <div>用户名：<input type="text" v-model="uname" @keyup.65="del" /></div>
      <div>
        密码：<input type="password" v-model="password" @keyup.f4="handle" />
      </div>
    </div>
    <script src="./js/vue.js"></script>
    <script>
      Vue.config.keyCodes.f4 = 115;
      var vm = new Vue({
        el: ".box",
        data: {
          uname: "",
          password: "",
        },
        methods: {
          handle(event) {
            console.log(this.uname, this.password);
          },
          del() {
            this.uname = "";
          },
        },
      });
    </script>
  </body>
</html>
